package thread;

import java.util.Scanner;

/**
 * sleep阻塞
 *
 * 线程提供了一个静态方法:
 * static void sleep(long ms)
 * 当一个线程调用sleep方法后就会进入阻塞状态指定毫秒
 */
public class SleepDemo {
    public static void main(String[] args)  {
        System.out.println("程序开始了");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数字");
        for (int i = scanner.nextInt(); i >0 ; i--) {
            System.out.println(i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("时间到了");
        System.out.println("程序结束了");
    }
}
